package com.woniu.controller.healthSystem;

import com.woniu.model.gh.common.Result;
import com.woniu.model.healthSystem.dto.AccountDto;
import com.woniu.model.healthSystem.entity.Account;
import com.woniu.service.healthSystem.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 职员表 前端控制器
 * </p>
 *
 * @author gb
 * @since 2023-10-19
 */
@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private IAccountService accountService;

    @GetMapping("/findAll")
    public Result findAll() {
        List<AccountDto> dtoList = accountService.findAll();
        return Result.ok(dtoList);
    }

    @PostMapping("/add")
    public Result add(@RequestBody Account account) {
        int row = accountService.addAccount(account);
        return Result.ok(row);
    }

    @GetMapping("/find")
    public Result find() {
        List<Account> list = accountService.list();
        return Result.ok(list);
    }

    @RequestMapping("/update")
    public Result update(@RequestBody Account account) {
        int row = accountService.update(account);
        return Result.ok(row);
    }

    @RequestMapping("/deleteById")
    public Result updateById(Long id) {
        int row = accountService.deleteById(id);
        return Result.ok(row);
    }




}
